#ifndef MYDATA_H
#define MYDATA_H

#include <QImage>

#define Lmax 6
#define Nmax 42

class MyData
{
public:
    MyData();
    double standerd_weight[26][Lmax*4+1];
    double ans_weight[26][Lmax*4+1];
    typedef struct Ft{
        int val[3][3];
        int cnt;
    }Ft;
    double study_rate = 0.1;
    QImage image;
    int table_erase[256]={
        0,0,1,1,0,0,1,1,1,1,0,1,1,1,0,1,\
        1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,\
        0,0,1,1,0,0,1,1,1,1,0,1,1,1,0,1,\
        1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,\
        1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,\
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
        1,1,0,0,1,1,0,0,1,1,0,1,1,1,0,1,\
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
        0,0,1,1,0,0,1,1,1,1,0,1,1,1,0,1,\
        1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,\
        0,0,1,1,0,0,1,1,1,1,0,1,1,1,0,1,\
        1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,\
        1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,\
        1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,\
        1,1,0,0,1,1,0,0,1,1,0,1,1,1,0,0,\
        1,1,0,0,1,1,1,0,1,1,0,0,1,0,0,0};

    int Letter[26][9][9]={
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	1,	1,	1,	0,	},
        {	0,	0,	0,	1,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	1,	1,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	1,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	1,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	1,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	1,	0,	0,	0,	1,	1,	0,	},
        {	0,	1,	0,	1,	0,	1,	0,	1,	0,	},
        {	0,	1,	0,	0,	1,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	1,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	1,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	1,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	1,	0,	1,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	1,	1,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	0,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	1,	1,	1,	1,	1,	1,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	1,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	1,	0,	0,	1,	0,	},
        {	0,	1,	0,	0,	1,	0,	0,	1,	0,	},
        {	0,	1,	0,	1,	0,	1,	0,	1,	0,	},
        {	0,	1,	1,	0,	0,	0,	1,	1,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	0,	1,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	0,	0,	0,	0,	0,	1,	0,	},
        {	0,	0,	1,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	1,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},
        {{	0,	0,	0,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	1,	1,	1,	1,	1,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	1,	0,	0,	},
        {	0,	0,	0,	0,	0,	1,	0,	0,	0,	},
        {	0,	0,	0,	0,	1,	0,	0,	0,	0,	},
        {	0,	0,	0,	1,	0,	0,	0,	0,	0,	},
        {	0,	0,	1,	0,	0,	0,	0,	0,	0,	},
        {	0,	1,	1,	1,	1,	1,	1,	1,	0,	},
        {	0,	0,	0,	0,	0,	0,	0,	0,	0,	},	},


    };
    int F_11[Lmax][3][3]={
        {
            {-1,1,-1,},
            {-1,1,-1,},
            {-1,1,-1,},

        },
        {
            {-1,-1,-1,},
            {1,1,1,},
            {-1,-1,-1,},
        },
        {
            {-1,-1,1,},
            {-1,1,-1,},
            {1,-1,-1,},
        },
        {
            {1,-1,-1,},
            {-1,1,-1,},
            {-1,-1,1,},
        },
        {
            {1,-1,1,},
            {-1,1,-1,},
            {1,-1,1,},
        },
        {
            {-1,1,-1,},
            {1,1,1,},
            {-1,1,-1,},
        },

    };
    int F_01[Lmax][3][3]={
        {
            {0,1,0,},
            {0,1,0,},
            {0,1,0,},
        },
        {
            {0,0,0,},
            {1,1,1,},
            {0,0,0,},
        },
        {
            {0,0,1,},
            {0,1,0,},
            {1,0,0,},
        },
        {
            {1,0,0,},
            {0,1,0,},
            {0,0,1,},
        },
        {
            {1,0,1,},
            {0,1,0,},
            {1,0,1,},
        },
        {
            {0,1,0,},
            {1,1,1,},
            {0,1,0,},
        },

    };

    double Calculate(int ord,int num);

    void Update(int ord,int num, double delta);

    void Graychange_image();

    void Filter_image();

    void Bitchange_image(int hold);

    void Thin_image();


};

#endif // MYDATA_H
